package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.CheckingAccount;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.Gender;
import com.acme.bankapp.domain.bank.SavingAccount;
import com.acme.exceptions.ClientDuplicateException;
import com.acme.exceptions.ClientNotExistException;
import com.acme.exceptions.NotEnoughFundsException;

public class BankApplication {
	private Bank db = new Bank();
		
	public static void main(String[] args) throws ClientNotExistException {
		BankApplication ba = new BankApplication();

		try {
			BankService.addClient(ba.db, new Client(new SavingAccount(10), "Ivanov", Gender.MALE));
		} catch (ClientDuplicateException e) {
			e.printStackTrace();
		}
		try {
			BankService.addClient(ba.db, new Client(new CheckingAccount(30,20), "Petrova", Gender.FEMALE));
		} catch (ClientDuplicateException e) {
			e.printStackTrace();
		}
		try {
			BankService.addClient(ba.db, new Client(new SavingAccount(20), "Sidorova", Gender.FEMALE));
		} catch (ClientDuplicateException e) {
			e.printStackTrace();
		}

		try {
			BankService.modifyBank(ba.db, 1, -20);
		} catch (NotEnoughFundsException e) {
			e.printStackTrace();
		}

		try {
			BankService.modifyBank(ba.db, 1, -21.34);
		} catch (NotEnoughFundsException e) {
			e.printStackTrace();
		}
		
		BankService.printBalance(ba.db);		

		Client cl = ba.db.getClientById(1);
		
		cl.checkAccount();

		System.out.println(cl.getAccount().toDecimalValue());
		
		CheckingAccount l1 = new CheckingAccount(20,30);
		CheckingAccount l2 = new CheckingAccount(20,30);

		System.out.println(l1.equals(l2));
	}
}
